import request from "../axios/request";

function getUserRecordTask(userId) {
    return new Promise((resolve, reject) => {
        request('get', '/recordTask/getUserRecordTask', {userId: userId})
            .then(res => {
                resolve(res)
            }, error => {
                reject(error)
            })
    })
}


function getUserRecordTaskInfoWithConditions(userId) {
    return new Promise((resolve, reject) => {
        request('get', '/recordTask/getUserRecordTaskInfoWithConditions', {
            userId: 13
        })
            .then(res => {
                resolve(res)
            }, err => {
                reject(err)
            })
    })
}

function getManagerAllRecordTaskCountInfo(userId) {
    return new Promise((resolve, reject) => {
        request('get', '/recordTask/getManagerAllRecordTaskCountInfo', {
            userId: userId
        })
            .then(res => {
                resolve(res)
            }, err => {
                reject(err)
            })
    })
}

function getRecordTaskListByStageAndListType(stage, listType, userId) {
    return new Promise((resolve, reject) => {
        request('get', '/recordTask/getRecordTaskListByStageAndListType', {
            userId: userId,
            stage: stage,
            listType: listType
        })
            .then(res => {
                resolve(res)
            }, err => {
                reject(err)
            })
    })
}

function getRecordTask(id) {
    return new Promise((resolve, reject) => {
        request("get", "/recordTask/getRecordTask", {id}).then(r => {
            resolve(r);
        }, e => {
            reject(e);
        })
    })
}

export {
    getUserRecordTask,
    getUserRecordTaskInfoWithConditions,
    getManagerAllRecordTaskCountInfo,
    getRecordTaskListByStageAndListType,
    getRecordTask,
}